#!/bin/bash

#------------------------------------------------------------------------------
#Filename:      84400-lvm.sh
#Version:       1.0
#Date:          2014/06/24
#Author:        xi.zhang
#Email:         xi.zhang@cs2c.com.cn
#Summary:       02.02系统管理功能-02逻辑卷管理-02字符命令-02移除/追加物理卷
#Notes:         测试卷组中物理卷的添加和删除
#Copyright:     China Standard Software Co.,Ltd.
#History:
#               Version 1.0,2014/06/24
#               -The first one
#               Version 1.1,2014/10/22
#               -The second one
#               -Add SFROOT
#               -Rename variables 
#               -Add notes
#               -Add CleanData Function 
#               -Add trap
#------------------------------------------------------------------------------

if [ -z "$SFROOT" ]
then
    CMDLIB=./
    SFROOT=./
else
    CMDLIB=${SFROOT}/testcases/Management_Function
fi

. ${SFROOT}/lib/UserOps.sh
. ${CMDLIB}/lib/Partition_parted.sh
. ${CMDLIB}/lib/PV.sh
. ${CMDLIB}/lib/VG.sh

IsRoot
EchoResult "脚本执行用户为root"

export PVNUM=2                  #物理卷数目
export VGNAME=vgroup-$$         #卷组名称

function CleanData()
{
  EchoInfo "Delete VG"
  DeleteVG

  EchoInfo "Delete PV"
  DeletePV
}

trap CleanData INT EXIT

GetHarddisk

CreatePV
EchoResult "Step 1 :Create PV"

CreateVG
EchoResult "Step 2 :Create VG"

#移除物理卷
SDA=`echo ${PV} | awk '{print $2}' `
vgreduce ${VGNAME} ${SDA}
EchoResult "Step 3 :Reduce PV"

#验证物理卷移除

#追加物理卷
vgextend ${VGNAME} ${SDA}
EchoResult "Step 4 :Extend PV"

#验证物理卷追加

